<?php
require("upload.php");

$status = "";
if ($_POST["action"] == "upload") {
	$fupload = new Upload();
	$fupload->setPath("../imagenes-news");
	$fupload->setFile("archivo");
	$fupload->isImage(true);
	$fupload->save();
	
	$status = $fupload->message;
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Subir archivo</title>
<link href="estilo.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="800" height="40" class="titulo">Subir archivo</td>
  </tr>
  <tr>
    <td class="text">Por favor seleccione el archivo a subir:</td>
  </tr>
  <tr>
  <form action="index.php" method="post" enctype="multipart/form-data">
    <td class="text">
      <input name="archivo" type="file" class="casilla" id="archivo" size="35" />
      <input name="enviar" type="submit" class="boton" id="enviar" value="Upload File" />
	  <input name="action" type="hidden" value="upload" />	  </td>
	</form>
  </tr>
  <tr>
    <td class="text" style="color:#990000"><?php echo $status; ?></td>
  </tr>
  <tr>
    <td height="30" class="subtitulo">Listado de Archivos Subidos </td>
  </tr>
  <tr>
    <td class="infsub">
	<?php 

	if ($gestor = opendir('../imagenes-news/')) {
		echo "<table>";
	    while (false !== ($arch = readdir($gestor))) {
		   if ($arch != "." && $arch != "..") {
		   echo "<tr>";
		   echo "<td><a href=\"../imagenes-news/".$arch."\" class=\"linkli\">".$arch."</a></td><td><img src='../imagenes-news/".$arch."'> </td>";
		   echo "</tr>";
		   }
	    }
	    closedir($gestor);
		echo "</table>";
	}

//	if ($gestor = opendir('../imagenes-news/')) {
//		echo "<ul>";
//	    while (false !== ($arch = readdir($gestor))) {
//		   if ($arch != "." && $arch != "..") {
//			   echo "<li><img src='../imagenes-news/".$arch."' width='100' height='100'> <a href=\"../imagenes-news/".$arch."\" class=\"linkli\">".$arch."</a></li>\n";
//		   }
//	    }
//	    closedir($gestor);
//		echo "</ul>";
//	}


#MALLLLLLLLLLLLLLLLLLLLLLLLLL
#			   echo "<li><a href=\"../imagenes-news/".$arch."\" class=\"linkli\">".$arch."</a></li>\n";

	#			$width=100;
	#			$height=100;
	#			$type="JPEG";
	#		    $archimg="../imagenes-news/".$arch;
	#			$imagen = exif_thumbnail($archimg, $width, $height, $type);
	#			header('Content-type: ' .image_type_to_mime_type($type));

#".echo $imagen."
	#			echo $imagen;
#echo $archimg;


#	if ($gestor = opendir('files')) {
#		echo "<ul>";
#	    while (false !== ($arch = readdir($gestor))) {
#		   if ($arch != "." && $arch != "..") {
#			   echo "<li><a href=\"files/".$arch."\" class=\"linkli\">".$arch."</a></li>\n";
#		   }
#	    }
#	    closedir($gestor);
#		echo "</ul>";
#	}

	?>



    </td>
  </tr>
</table>
</body>
</html>
